﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

public partial class _Default : System.Web.UI.Page
{
    //connDB myConn = new connDB();
    //email myMail = new email();
    string phone,cphone, major, state, athInt, howhear, rdgrpStu; string sGuid;
    protected void Page_Load(object sender, EventArgs e)
    {
        txtArea.Attributes.Add("onkeyup", "return parea()");
        txtPrefix.Attributes.Add("onkeyup", "return pprefix()");
        txtSuffix.Attributes.Add("onkeyup", "return psuffix()");
        txtArea0.Attributes.Add("onkeyup", "return marea()");
        txtPrefix0.Attributes.Add("onkeyup", "return mprefix()");
        txtSuffix0.Attributes.Add("onkeyup", "return msuffix()");
        //Accept only number you cannot type letters
        //txtArea.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");
        //txtPrefix.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");
        //txtSuffix.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");
        //txtArea0.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");
        //txtPrefix0.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");
        //txtSuffix0.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");

        //txtZip.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");
        //txtGradDate.Attributes.Add("onkeydown", "return isNumeric(event.keyCode);");


        lblMsg.Visible = true;
        if (!IsPostBack)
        {
            PopulateTime();
            //ddMajor.Items.Add("Select One");
            //myConn.PopulateMajor(ddMajor);
            ddMajor.Items.Add(new ListItem("Select One", " "));
            ddMajor.SelectedValue = " ";
            ddMajor_SelectedIndexChanged(ddMajor, e);
            ddState2_SelectedIndexChanged(ddState2, e);
            ddHowHear_SelectedIndexChanged(ddHowHear, e);
            ddAthInt_SelectedIndexChanged(ddAthInt, e);

        }
    }

    private void PopulateTime()
    {
        ddVisitTime.Items.Add(" ");
        for (int i = 9; i < 13; i++)
        {

            if (i > 8 && i < 12)
                ddVisitTime.Items.Add(i.ToString() + " AM");
            //if (i == 12)
            //    ddVisitTime.Items.Add(i.ToString() + " Noon");


        }
        for (int j = 1; j < 3; j++)
        {
            ddVisitTime.Items.Add(j.ToString() + " PM");

        }





    }
    protected void ddState2_SelectedIndexChanged(object sender, EventArgs e)
    {
        state = ddState2.SelectedValue.ToString();

    }
    protected void ddMajor_SelectedIndexChanged(object sender, EventArgs e)
    {

        major = ddMajor.SelectedValue.ToString();


    }


    protected void ddAthInt_SelectedIndexChanged(object sender, EventArgs e)
    {
        athInt = ddAthInt.SelectedValue.ToString();
    }
    protected void ddHowHear_SelectedIndexChanged(object sender, EventArgs e)
    {
        howhear = ddHowHear.SelectedValue.ToString();
    }


    protected void btnSubmit_Click(object sender, EventArgs e)
    {

        if (ValidTime())
        {
            if (Page.IsValid)
            {
                setstate();
                //Insert campusvisit Table
                save();
                string strToMe = "Mallika.Ramaswamy@Avila.edu";
                string strTo = "Admission@Avila.edu ";
                string strSubject = "Campus Visit Request From First year Student " + DateTime.Now.ToString();
                string strFrom = txtEmail.Text.Trim();
                string msgStr = "";
                msgStr = msgStr + "<table width=108% border=0 align=left cellpadding=0 cellspacing=0 style=font-family:arial;font-size:11px;><tr>";
                msgStr = msgStr + " <td width=3 rowspan=73 valign=top>&nbsp;</td>";
                msgStr = msgStr + " <td colspan=2 align=left valign=top bgcolor=#F4F4F4>Contact Information </td>";
                msgStr = msgStr + " <td width=17 align=left valign=top bgcolor=#F4F4F4>&nbsp;</td>";
                msgStr = msgStr + " <td width=159 align=left valign=top bgcolor=#F4F4F4>&nbsp;</td>";
                msgStr = msgStr + " <td width=151 align=left valign=top bgcolor=#F4F4F4>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + "<td width=145 align=left valign=middle><strong>First Name</strong></td>";
                msgStr = msgStr + "<td width=200 align=left valign=top>";
                msgStr = msgStr + txtFName.Text.Trim();
                msgStr = msgStr + "</td><td align=left valign=middle>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=middle><strong>Street 1</strong></td>";
                msgStr = msgStr + "<td align=left valign=top>";
                msgStr = msgStr + txtStreet1.Text.Trim();
                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + " <td align=left valign=middle ><strong>Middle Name</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>";
                msgStr = msgStr + txtMName.Text.Trim();
                msgStr = msgStr + "</td> <td align=left valign=middle>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=middle><strong>Street 2</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>" + txtStreet2.Text.Trim();
                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + " <td align=left valign=middle ><strong>Last Name</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>";
                msgStr = msgStr + txtLName.Text.Trim();
                msgStr = msgStr + "</td> <td align=left valign=middle>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=middle><strong>City</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>" + txtCity.Text.Trim();
                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + " <td align=left valign=middle ><strong>Home Phone</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>";
                msgStr = msgStr + phone;
                msgStr = msgStr + "</td> <td align=left valign=middle>&nbsp;</td>"; ;
                msgStr = msgStr + " <td align=left valign=middle><strong>State/Province</strong></td>"; ;
                msgStr = msgStr + " <td align=left valign=top>" + ddState2.SelectedValue.ToString();
                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + " <td align=left valign=middle ><strong>Mobile Phone</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>";
                msgStr = msgStr + cphone;
                msgStr = msgStr + "</td> <td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top ><strong>Zip Code</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>" + txtZip.Text.Trim();
                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + " <td align=left valign=top ><strong>E-Mail address</strong></td>";
                msgStr = msgStr + " <td align=left valign=top>" + txtEmail.Text.Trim();
                msgStr = msgStr + "</td> <td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top ></td></tr><tr>";


                msgStr = msgStr + " <td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + " <td colspan=2 align=left valign=top bgcolor=#F4F4F4><strong>Education Information</strong></td>";
                msgStr = msgStr + " <td align=left valign=top bgcolor=#F4F4F4>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top bgcolor=#F4F4F4>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top bgcolor=#F4F4F4><a href=#></a></td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + " <td colspan=2 align=left valign=middle ><strong>School Currently or Last Attended</strong><br />";
                msgStr = msgStr + txtSchool.Text.Trim();

                msgStr = msgStr + "</td> <td colspan=3 align=left valign=top ><strong>Anticipated Graduation Year</strong><br />";
                msgStr = msgStr + txtGradDate.Text.Trim();
                msgStr = msgStr + "</td></tr><tr>";

                msgStr = msgStr + "<td colspan=2 align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td colspan=2 align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr>";

                msgStr = msgStr + " <td colspan=2 align=left valign=middle ><strong>ACT Score</strong><br />";
                msgStr = msgStr + txtACTScore.Text.Trim();

                msgStr = msgStr + "</td> <td colspan=3 align=left valign=top ><strong>SAT Composite</strong> <span class=alumniTxt>(Critical Reading + Math)</span><br />";
                msgStr = msgStr + txtSATcomp.Text.Trim();
                msgStr = msgStr + "</td></tr>";


                msgStr = msgStr + "<tr><td colspan=2 align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + " <td colspan=2 align=left valign=top ><strong>Intended Major</strong></td>";
                msgStr = msgStr + " <td colspan=3 align=left valign=top ><strong>Athletic Interests</strong><br /></td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + "<td colspan=2 align=left valign=top class=style13>" + ddMajor.SelectedItem.Text;
                msgStr = msgStr + "</td><td colspan=3 align=left valign=top >" + ddAthInt.SelectedValue;
                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + " <td colspan=2 align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + " <td colspan=2 align=left valign=top bgcolor=#F4F4F4><strong>Visit and Miscellaneous Information</strong></td>";
                msgStr = msgStr + " <td align=left valign=top bgcolor=#F4F4F4>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top bgcolor=#F4F4F4>&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top bgcolor=#F4F4F4><a href=#></a></td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + "<td colspan=5 align=left valign=top>";

                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + "<td colspan=2 align=left valign=top ><strong>How did you hear about Avila?</strong></td>";
                msgStr = msgStr + "<td colspan=2 align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr><td colspan=2 align=left valign=top >" + ddHowHear.SelectedValue;
                msgStr = msgStr + "</td><td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + "<td align=left valign=top class=style13>&nbsp;</td>";
                msgStr = msgStr + "<td colspan=3 align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr>";
                msgStr = msgStr + "<td height=2 colspan=5 align=left valign=top><strong>List others you would  like to meet with such as an academic, athletic, or other person?&nbsp; </strong></td>";
                msgStr = msgStr + "</tr><tr><td colspan=3 align=left valign=top>";
                msgStr = msgStr + txtarOther.Text.Trim();
                msgStr = msgStr + "</td><td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "</tr><tr><td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top>&nbsp;</td></tr>";
                //msgStr = msgStr + "<tr><td colspan=2 align=left valign=top ><strong>Would you like to visit on a Saturday?</strong></td>";
                //msgStr = msgStr + "<td colspan=2 align=left valign=top >" + rbSat.SelectedItem.Text  + "</td></tr>";

                //if (rbSat.SelectedValue.ToString() == "N")
                //{
                msgStr = msgStr + "<tr><td colspan=2 align=left valign=top ><strong>When would you like to visit?</strong></td>";
                msgStr = msgStr + "<td colspan=3 align=left valign=top ><strong>Choose a visit start time:</strong></td>";
                msgStr = msgStr + "</tr><tr><td colspan=2 align=left valign=top >" + txtVisitDate.Text.Trim();

                msgStr = msgStr + "</td><td colspan=3 align=left valign=top >" + ddVisitTime.SelectedValue;

                msgStr = msgStr + "</td></tr><tr><td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td colspan=2 align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + "<td align=left valign=top >&nbsp;</td></tr>";


                //}
                //else if (rbSat.SelectedValue.ToString() == "Y")
                //{

                //    msgStr = msgStr + "<tr><td colspan=2 align=left valign=top ><strong>When would you like to visit?</strong></td>";
                //    msgStr = msgStr + "<td colspan=3 align=left valign=top ><strong>Choose a visit start time:</strong></td>";
                //    msgStr = msgStr + "</tr><tr><td colspan=2 align=left valign=top >" + txtSatVisitDate.Text.Trim();

                //    msgStr = msgStr + "</td><td colspan=3 align=left valign=top >" + ddSatVisitTime.SelectedValue;

                //    msgStr = msgStr + "</td></tr><tr><td align=left valign=top >&nbsp;</td>";
                //    msgStr = msgStr + "<td align=left valign=top >&nbsp;</td>";
                //    msgStr = msgStr + "<td colspan=2 align=left valign=top >&nbsp;</td>";
                //    msgStr = msgStr + "<td align=left valign=top >&nbsp;</td></tr>";




                //}

                msgStr = msgStr + "<tr><td colspan=2 align=left valign=top ><strong>Who is filling out this form?</strong></td>";
                msgStr = msgStr + "<td colspan=3 align=left valign=top ><strong>How did you hear about Avila? </strong></td>";
                msgStr = msgStr + "</tr><tr><td colspan=2 align=left valign=top >" + rbWho.Text.Trim();
                msgStr = msgStr + "</td><td colspan=3 align=left valign=top >" + ddHowHear.SelectedValue.ToString();
                msgStr = msgStr + "</td></tr><tr>";
                msgStr = msgStr + "<td colspan=2 align=left valign=top >&nbsp;</td>";
                msgStr = msgStr + " <td align=left valign=top >&nbsp;</td></tr></table>";

                string msgStu = "";
                msgStu = " Thank you for submitting the Campuvisit on " + DateTime.Now.ToString() + "<br/>";
                msgStu += " We will review your information and Admission rep will contact you soon. <br/>";
                msgStu += msgStr;
                //Confirmation Email send to student/visitor


               // myMail.sendMail(msgStu, strTo, strFrom, strSubject);
                //To Admission
               // myMail.sendMail(msgStr, strFrom, strTo, strSubject);

                //To me
               // myMail.sendMail(msgStr, strFrom, strToMe, strSubject);
               // myMail.sendMail(msgStr, strFrom, "Laura.Harrity@avila.edu", strSubject);
                Response.Redirect("thanks.aspx");
               //Session.Abandon();

            }
        }
        else
        {

            ddVisitTime.Focus();
            lblErrTime.ForeColor = Color.Red;
            lblErrTime.Text = "ALERT! You can choose 9AM & 10AM (OR) 1PM & 2PM !";


        }

    }


    private void setstate()
    {
        Session["FirstName"] = txtFName.Text.Trim();

        if (txtMName.Text != "")
            Session["MName"] = txtMName.Text.Trim();
        else
        {
            txtMName.Text = "-----";
            Session["MName"] = txtMName.Text.Trim();
        }


        Session["LastName"] = txtLName.Text.Trim();
        Session["Street"] = txtStreet1.Text.Trim();
        if (txtStreet2.Text != "")
        {
            Session["Add2"] = txtStreet2.Text.Trim();
        }
        else
        {
            txtStreet2.Text = "-----";
            Session["Add2"] = txtStreet2.Text.Trim();

        }
        Session["City"] = txtCity.Text;
        Session["State"] = ddState2.SelectedValue.ToString();
        Session["Zip"] = txtZip.Text;
        Session["Email"] = txtEmail.Text;
        Session["LastSchool"] = txtSchool.Text;

        Session["GradDate"] = txtGradDate.Text;
        if (txtACTScore.Text != "")
            Session["ACTS"] = txtACTScore.Text;
        else
        {
            txtACTScore.Text = "Not Provided";
            Session["ACTS"] = txtACTScore.Text;
        }
        // Session["ACTAgain"] = rbACTAgain.SelectedValue.ToString();
        if (txtSATcomp.Text != "")
            Session["SAT"] = txtSATcomp.Text;
        else
        {
            txtSATcomp.Text = "Not Provided";
            Session["SAT"] = txtSATcomp.Text;
        }
        // Session["GPA"] = txtGPA.Text;

        Session["Major"] = ddMajor.SelectedItem.Text;
        Session["AthInt"] = ddAthInt.SelectedValue.ToString();
        Session["HowHear"] = ddHowHear.SelectedValue.ToString();

        // Session["Applied"] = rbApplied.SelectedValue.ToString();

        Session["WhoFill"] = rbWho.SelectedValue.ToString();
       // Session["rdgrpStu"] = Label1.Text;
        if (txtarOther.Text != "")
            Session["listOther"] = txtarOther.Text.Trim();
        else
        {
            txtarOther.Text = "----------";
            Session["listOther"] = txtarOther.Text.Trim();
        }


        if (txtArea.Text != "" && txtPrefix.Text != "" && txtSuffix.Text != "")
        {
            phone = txtArea.Text + '-' + txtPrefix.Text + '-' + txtSuffix.Text;
            Session["Phone"] = phone;
        }

        else
        {
            phone = "Not Provided";
            Session["Phone"] = phone;


        }

        if (txtArea0.Text != "" && txtPrefix0.Text != "" && txtSuffix0.Text != "")
        {
            cphone = txtArea0.Text + '-' + txtPrefix0.Text + '-' + txtSuffix0.Text;
            Session["CPhone"] = cphone;
        }

        else
        {
            cphone = "Not Provided";
            Session["CPhone"] = cphone;


        }
        // Added for Saturday

        //Session["rbSat"] = rbSat.SelectedItem.Text;
        //if (rbSat.SelectedValue.ToString() == "N")
        //{
        Session["VisitDate"] = txtVisitDate.Text;
        Session["VisitTime"] = ddVisitTime.SelectedValue.ToString();

        //}
        //else if (rbSat.SelectedValue.ToString() == "Y")
        //{
        //    Session["VisitDate"] = txtSatVisitDate.Text;
        //    Session["VisitTime"] = ddSatVisitTime.SelectedValue.ToString();

        //}

    }
    private bool ValidTime()
    {
        //working --added for testing
        //if (txtVisitDate.Text == "03/16/2015" && ddVisitTime.SelectedValue.ToString() == "2 PM")
        //{
        //    lblErrTime.ForeColor = Color.Red;
        //    lblErrTime.Text = "March 16- You can choose between 9 AM - 1 PM ";
        //    ddVisitTime.SelectedValue = " ";
        //    return false;
        //}
        //else
        //{
        //    lblErrTime.Text = "";
        //}
        return true;

      
    }

    private void save()
    {
        // In case Client press the back button ,lock the data for the particular application
        Application.Lock();
        setstate();

        if (Convert.ToString(Session["appGuid"]) != "")
            sGuid = Session["appGuid"].ToString();
        else
        {
            Session["appGuid"] = Guid.NewGuid();
            sGuid = Session["appGuid"].ToString();
        }
        string pterm = null; 
        string stype = "FirstYear";
        string visit = txtVisitDate.Text + " @ " + ddVisitTime.SelectedValue;
        //myConn.AddInfo(sGuid, txtFName.Text, txtLName.Text, txtPre.Text, txtMName.Text, txtStreet1.Text, txtStreet2.Text, txtCity.Text, ddState2.SelectedValue,
        //    txtZip.Text, txtEmail.Text, txtSchool.Text, txtGradDate.Text, cphone, phone, txtACTScore.Text,
        //    txtSATcomp.Text, ddMajor.SelectedValue, pterm, stype, ddAthInt.SelectedValue, visit, txtarOther.Text, ddHowHear.SelectedValue, rbWho.SelectedValue);



        Application.UnLock();

    }



    protected void ddVisitTime_SelectedIndexChanged(object sender, EventArgs e)
    {


        txtarOther.Focus();
        //ValidTime();

    }


    
}


// FROM OLD Apps not used now --I am using only valid time 
//Added for Saturday till May 5th after that remove these codes



//protected void rbSat_SelectedIndexChanged(object sender, EventArgs e)
//{
//    string sel = rbSat.SelectedValue.ToString();

//    switch (sel)
//    {
//        case "Y":
//            pnlSat.Visible = true;
//            pnlReg.Visible = false;
//            break;
//        case "N":
//            pnlSat.Visible = false;
//            pnlReg.Visible = true;
//            break;
//        default:
//            pnlSat.Visible = false;
//            pnlReg.Visible = false;
//            break;
//    }

//}

//protected void SatCalenderDayRenderMethod(object sender, DayRenderEventArgs e)
//{
//    // Select all dates in the past

//    if (e.Day.Date < (System.DateTime.Now))
//    {

//        e.Day.IsSelectable = false;
//        //e.Cell.Font.Strikeout = true;
//        e.Cell.ForeColor = Color.Gray;

//    }

//    if (e.Day.IsToday)
//    {
//        e.Day.IsSelectable = true;
//        e.Cell.ForeColor = Color.Blue;
//    }


//    if (e.Day.Date >= Convert.ToDateTime("05/12/2012"))
//    {
//        if (e.Day.IsWeekend)
//        {
//            e.Day.IsSelectable = false;
//            e.Cell.ForeColor = Color.Gray;

//        }



//    }

//    if (e.Day.Date <= Convert.ToDateTime("05/12/2012"))
//    {
//        if (e.Day.Date.DayOfWeek.ToString() != "Saturday")// && e.Day.Date  < Convert.ToDateTime("05/12/2012") )
//        {
//            e.Day.IsSelectable = false;
//            e.Cell.ForeColor = Color.Gray;
//        }
//    }

//    if (e.Day.IsWeekend)
//    {

//        if (e.Day.Date.DayOfWeek.ToString() != "Saturday")// && e.Day.Date  < Convert.ToDateTime("05/12/2012") )
//        {


//            e.Day.IsSelectable = false;
//            //e.Cell.Font.Strikeout = true;
//            e.Cell.ForeColor = Color.Gray;
//        }



//    }

//    // Disable the Between Particular dates
//    blockHolidays(e, "3/17/2012");
//    blockHolidays(e, "4/7/2012");

//    blockHolidays(e, "4/21/2012");




//    string startDate, endDate;

//    startDate = "4/21/2011";
//    endDate = "4/22/2011";
//    blockDates(e, startDate, endDate);





//}



//Not working without calendar control So use the above validtime
//private bool ValidTime()
//{
//    if (Calendar1.SelectedDate == Convert.ToDateTime("5/16/14") && (ddVisitTime.SelectedValue == "1 PM" || ddVisitTime.SelectedValue == "2 PM")) //>= Convert.ToDateTime("12/9/13") && Calendar1.SelectedDate <= Convert.ToDateTime("1/8/2014")) && (ddVisitTime.SelectedValue == "12 Noon" || ddVisitTime.SelectedValue == "11 AM" || ddVisitTime.SelectedValue == "3 PM"))
//    {
//        //Calendar1.Attributes.Add("onclick", "javascript:alert('From 12/9/2013 to  1/8/2014. You can choose between 9 AM - 11 AM or 1 PM - 3 PM! ');");

//        string msg = "On May 16th 2014. ";
//        msg += "\n" + "You can choose only 9 AM & 10 AM !   ";
//        lblMsg.Visible = true;
//        lblMsg.BackColor = Color.Yellow;
//        lblMsg.ForeColor = Color.Red;
//        lblMsg.Text = msg;
//        //MessageBox.Show(msg, "ALERT", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
//        ddVisitTime.SelectedValue = " ";
//        ddVisitTime.Focus();
//        return false;
//    }
//    else
//    {

//        lblMsg.Visible = false;
//        lblMsg.Text = "";
//    }
//    return true;
//}
////For Calender1 Control: SatCalendar
//protected void SatCalendar_SelectionChanged(object sender, EventArgs e)
//{
//    PopupControlExtender2.Commit(SatCalendar.SelectedDate.ToShortDateString());
//}

//protected void txtVisitDate_Disposed(object sender, EventArgs e)
//{
// Poppulatedd();
//}

//private void Poppulatedd()
//{



//for (int i = 9; i < 13; i++)
//{

//    if (i > 8 && i < 12)

//        ddVisitTime.Items.Add(i.ToString() + " AM");
//    //if (i == 12)

//    //    ddVisitTime.Items.Add(i.ToString() + " Noon");

//}

//ddVisitTime.Items.Add("1 PM");

//}


//protected void ddVisitTime_SelectedIndexChanged(object sender, EventArgs e)
//{
//    ValidTime();



//}


//Old ValidTime
//private bool  ValidTime()
//{
//    if ( txtVisitDate.Text == "12/14/2012" &&  ddVisitTime.SelectedValue.ToString() == "2 PM" )

//    {
//        lblErrTime.ForeColor = Color.Red;
//        lblErrTime.Text = "December 14 - You can choose between 9 AM - 1 PM " ;
//        ddVisitTime.SelectedValue = " ";
//        return false ;
//    }
//    else if (txtVisitDate.Text == "12/14/2012" && ddVisitTime.SelectedValue.ToString() == "3 PM")
//    {
//        lblErrTime.ForeColor = Color.Red;
//        lblErrTime.Text = "December 14 - You can choose between 9 AM - 1 PM ";
//        ddVisitTime.SelectedValue = " ";
//        return false;
//    }
//    else if (txtVisitDate.Text != "12/14/2012" || ddVisitTime.SelectedValue.ToString() != "3 PM" || ddVisitTime.SelectedValue.ToString() != "2 PM") 
//    {
//        lblErrTime.Text = "";
//        return true;
//    }
//   // else if( (Convert.ToDateTime (txtVisitDate.Text) >= Convert.ToDateTime("12/17/2012") &&  Convert.ToDateTime (txtVisitDate.Text) <= Convert.ToDateTime("12/17/2012")) 



//    //lblErrTime.Text = "";
//    return true;


//}